package com.wuyangnju.healthclub.util;

import java.lang.reflect.InvocationTargetException;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import org.apache.commons.beanutils.BeanUtils;

/**
 * Virtual Date
 * 
 * @author Administrator
 * 
 */
public class VirDate {

	private static VirDate virDate = new VirDate();

	private VirDate() {
		calendar = new GregorianCalendar();
		calendar.set(Calendar.YEAR, 2009);
		calendar.set(Calendar.MONTH, 9 - 1);
		calendar.set(Calendar.DAY_OF_MONTH, 1);
	}

	public static VirDate get() {
		return virDate;
	}

	private Calendar calendar;

	public Date getDate() {
		return calendar.getTime();
	}

	public void oneMonthPassBy() {
		calendar.add(Calendar.MONTH, 1);
		calendar.set(Calendar.DAY_OF_MONTH, 1);
	}

	public void oneDayPassBy() {
		calendar.add(Calendar.DAY_OF_MONTH, 1);
	}

	public Calendar copyCalendar() {
		try {
			return (Calendar) BeanUtils.cloneBean(calendar);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		}
		return null;
	}

}
